#pragma once

#include "image.h"
#include "tensor.h"
#include <vector>
#include <memory>
#include <cstdint>

namespace vkinfer
{
	struct Rect
	{
		uint32_t x;
		uint32_t y;
		uint32_t width;
		uint32_t height;
	};

	struct AffineMatrix
	{
		float m[2][3] = { {0, 0, 0}, {0, 0, 0} };

	public:
		AffineMatrix() {}
		AffineMatrix(uint32_t src_width, uint32_t src_height, uint32_t dst_width, uint32_t dst_height);
		AffineMatrix(const Rect& src, const Rect& dst);
		AffineMatrix inverse() const;
		void apply(float x, float y, float* px, float* py);
	};

	struct ImagePreprocessor
	{
		// resize
		uint32_t width;
		uint32_t height;

		// normalization
		bool channel_shuffle; // rgb2bgr
		bool hwc2chw;
		bool normalize;
		std::vector<float> mean; // in rgb format.
		std::vector<float> std;

	public:
		ImagePreprocessor();

		std::shared_ptr<Tensor<float>> process(const Image& image);
	};

	// simple display image with vulkan.
	void display_image(const Image& image);
}
